import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    // 本地有token,从本地获取token,没token就赋值null
    userState: JSON.parse(localStorage.getItem('userState')) || null,
    // 总的评论数量,文章底部tabbar要用
    commentTotal: 0
  },
  mutations: {
    // 设置用户状态,即token
    setUserState (state, playlod) {
      state.userState = playlod
      localStorage.setItem('userState', JSON.stringify(state.userState))
    },
    setCommentTotal (state, playlod) {
      console.log('23')
      state.commentTotal = playlod.commentToal
    }
  },
  actions: {
  },
  modules: {
  }
})
